import { LayerInfoBE, LayerInfoFE, LayerRatioInfoBE } from './common';

export enum TemplateStatus {
  Draft = 0,
  PendingApprove,
  Rejected,
  ReadyToUse
}

export interface TemplateInfo {
  templateId?: number;
  templateName?: string;
  market?: string;
  templateSize?: string;
  templateStatus?: TemplateStatus;
  lastEditBy?: string;
  lastEditTime?: number;
  templateThumbnailUrl?: string;
  errorReasonCode?: number;
  remark?: string;
  hasApplied?: boolean;
}

export interface LayerActionType {
  updateLayerInfo?: string;
  updateLayerInfoNoHistory?: string;
}

export interface TemplateDetailInfoBE extends TemplateInfo {
  templateId: number;
  templateName: string;
  templateStatus: TemplateStatus;
  templateSize: string;
  layerInfo: LayerRatioInfoBE;
  layers: LayerInfoBE[];
  feLayers?: LayerInfoFE[]; // 前端用
}

export interface TemplateIssue {
  layerId: string;
  issueTitle: string;
  issueContent: string;
  issueCount: number;
}

export interface ICreateTemplateParam {
  templateName: string;
  templateSize: [number, number];
  isDraft: boolean;
  layers: Array<LayerInfoBE>;
  layerInfo: LayerRatioInfoBE;
}

export interface IEditTemplateParam extends ICreateTemplateParam {
  lockSequence: string;
}

export interface CampaignBaseInfo {
  id: string;
  name: string;
}

export interface TemplateListInfo {
  templateId: number;
  templateName: string;
  templateImageUrl: string;
}

export interface AllLayerPosition {
  [key: string]: number[];
}

export interface ReferenceLinePosition {
  lineX?: number;
  targetX?: number;
  lineY?: number;
  targetY?: number;
}

export interface DrawReferLine {
  show: boolean;
  linePosition?: number;
}

export interface DrawReferLineParam {
  // x: DrawReferLine;
  // y: DrawReferLine;
  showX: boolean;
  showY: boolean;
  linePositionX?: number;
  linePositionY?: number;
}

export interface TemplateHistoryItem {
  type: string;
  payload: any;
  beforeLayerState?: any;
  afterLayerState?: any;
  beforeLayerIds?: any;
}

export interface TemplateHistory {
  list: TemplateHistoryItem[];
  index: number;
}

export interface PreviewLayerInfo {
  id: string;
  textLayerImage?: string;
  errorMessage?: string;
}
export interface ProductAndTextLayerBody {
  layers: LayerInfoBE[] | string;
  templateSize: string;
}

export interface TextLayerResponse {
  textLayers: PreviewLayerInfo[];
}

export interface RealTimePreviewProps {
  layers?: LayerInfoFE[];
  index: number;
  direction?: number;
  alignLatestLayers?: boolean; // 请求数据回来之后，是否用最新的 layers 进行合并
}
